home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / FAQ.SWG / 0018_Accessing locals in BASM.pas < prev    next >
Pascal/Delphi Source File  |  1993-11-02  |  777b  |  35 lines

  1. {
  2. RAPHAEL VANNEY
  3.  
  4. > I've got a question about BAsm: How would I go about accessing a local
  5. > Variable in an assembly block?  I know that locals are stored on the
  6. > stack: Var temp:Byte;
  7. }
  8.  
  9. Procedure TestLocal(Var a : Integer); Assembler;
  10. Var
  11.   i    : Byte;
  12.   Stri : String;
  13. Asm
  14.   { Getting Pointers... }
  15.   Push SS
  16.   Pop  ES
  17.   LEA  SI, i     { ES:SI points to i }
  18.   LEA  DI, Stri  { ...and ES:DI points to Stri }
  19.  
  20.   { if you Really need DS as a segment... }
  21.   Push DS        { Save DS }
  22.   Mov  AX, SS    { Copy SS to AX... }
  23.   Mov  DS, AX    { ...then to DS }
  24.   LEA  DX, Stri  { DS:DX points to Stri }
  25.   Pop  DS        { Restore DS }
  26.  
  27.   LES  DX, a     { ES:DX points to a }
  28.  
  29.   { Now using local Vars }
  30.   Inc  i
  31.   Mov  i, 10
  32.   { etc... }
  33. end;
  34.  
  35.